package br.com.news.activity.json;

import java.io.Reader;
import java.lang.reflect.Type;
import java.util.List;

import br.com.news.modal.interfaces.IBaseBean;

import com.google.gson.Gson;

/**
 * 
 * @author Jefferson
 * @since 26/03/2013
 */
public class ParseJson<T extends IBaseBean> {

	/**
	 * Parse de um objeto
	 * 
	 * @param T
	 * @param Reader
	 * @return T
	 */
	public T parseObject(Class<T> t, Reader reader){
		Gson gson = new Gson();
		return gson.fromJson(reader, t);
	}
	
	/**
	 * Parse de uma lista
	 * 
	 * @param T
	 * @param Reader
	 * @return List<T>
	 */
	public List<T> parseObjectList(Type t, Reader reader){
		Gson gson = new Gson();
		return gson.fromJson(reader, t);
	}
	
}
